import {useAxios} from '@/hooks/web/useAxios'
import type {QueryParams, FormData, EqParams, DeptId, VisitNo} from './types'
import {VisitNos} from "./types";

const request = useAxios()

//患者登记列表
export const listReg = (params: QueryParams) => {
    params.dataType = "TJ01"
    return request.get({
        url: '/system/patient/list',
        params
    })
}

//新增
export const addREG = (data: FormData) => {
    data.dataType = "TJ01"
    return request.post({
        url: '/system/patient',
        data
    })
}

//身份证号查询获取基本信息
export const searchId = (params: { identityNumber: StrUn }) => {
    return request.get({
        url: '/system/patient/baseInfo',
        params
    })
}

//根据设备类型查看可用设备列表
export const eqList = (params: EqParams) => {
    return request.get({
        url: '/system/equipment/getOptionData',
        params
    })
}

//根据科室ID获取医生列表
export const doctorTree = (params: DeptId) => {
    return request.get({
        url: '/system/user/doctorTree',
        params
    })
}

//查询患者详情
export const getPatInfo = (params: { visitNo: string }) => {
    return request.get({
        url: '/system/patient/' + params.visitNo,
    })
}

//查询患者详细信息
export const getPatDatailInfo = (params: { visitNo: string }) => {
    return request.get({
        url: '/system/patient/info/' + params.visitNo,
    })
}

//修改患者登记
export const updateReg = (data: FormData) => {
    data.dataType = "TJ01"
    return request.put({
        url: '/system/patient',
        data
    })
}

//出院
export const DC = (params: VisitNo) => {
    return request.put({
        url: '/system/patient/leaveHospital',
        params
    })
}

//批量出院
export const batchDc = (params: VisitNos) => {
    return request.put({
        url: '/system/patient/batchLeaveHospital',
        params
    })
}

//删除患者
export const delReg = (params: VisitNo) => {
    return request.delete({
        url: '/system/patient/' + params.visitNo,
    })
}

// 患者列表(医院账号)
export const allListReg = (params: QueryParams) => {
    params.dataType = "TJ01"
    return request.get({
        url: '/system/patient/allList',
        params
    })
}

// 获取患者报告数据，用于打印
export const getPatientReportData = (params) => {
    return request.get({
        url: '/system/reports/tj01/getSleepReportData',
        params
    })
}

// 获取患者报告数据，用于小程序打印
export const getMattressReportData = (params) => {
    return request.get({
        url: '/applet/mattress/report/getMattressReportData',
        params
    })
}